package cn.seapon.talker.common;

import org.json.JSONObject;

/** 
 * @author 作者 E-mail: 
 * @version 创建时间：2015年1月10日 下午3:49:58 
 * 类说明 
 */
public class FriendRequestEntity {
	
	private String receiver = "";
	private String text = "";
	private UserInformation information = null;
	
	public JSONObject getJsonObject() {
		JSONObject object = new JSONObject();
		try {
			object.put("receiver", receiver);
			object.put("text", text);
			object.put("infomation", information.getJSONObject());
			return object;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	public String getJsonString() {
		return getJsonObject().toString();
	}
	
	public static FriendRequestEntity getObjectFromJson(JSONObject object) {
		FriendRequestEntity entity = new FriendRequestEntity();
		try {
			entity.setText(object.getString("text"));
			entity.setReceiver(object.getString("receiver"));
			UserInformation information = UserInformation.getObjectFromJson(object.getJSONObject("infomation"));
			entity.setInformation(information);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		return entity;
	}
	
	

	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public UserInformation getInformation() {
		return information;
	}

	public void setInformation(UserInformation information) {
		this.information = information;
	}

	public FriendRequestEntity() {
		// TODO Auto-generated constructor stub
	}

}
